package com.ruoyi.web.controller.park;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.park.domain.CompanySignContract;
import com.ruoyi.park.service.ICompanySignContractService;
import com.ruoyi.system.domain.SysNotice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

@RestController
@RequestMapping("/company/sign/contract")
public class CompanySignContractController extends BaseController {

    @Autowired
    ICompanySignContractService companySignContractService;

    /**
     * 获取列表
     */
    @GetMapping("/pageList")
    public IPage list(CompanySignContract companySignContract,@RequestParam Long pageNo,@RequestParam Long pageSize)
    {
        IPage<CompanySignContract> page = new Page(pageNo,pageSize);
        IPage list = companySignContractService.page(page,new QueryWrapper<>(companySignContract));
        return list;
    }
    /**
     * 新增
     */
    @GetMapping("{id}")
    public AjaxResult getById(@PathVariable Long id)
    {
        return AjaxResult.success(companySignContractService.getById(id));
    }


    /**
     * 新增
     */
    @PostMapping
    public AjaxResult add(@Validated @RequestBody CompanySignContract companySignContract)
    {
        return toAjax(companySignContractService.save(companySignContract));
    }

    /**
     * 修改
     */
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody CompanySignContract companySignContract)
    {
        return toAjax(companySignContractService.updateById(companySignContract));
    }

    /**
     * 删除
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(companySignContractService.removeByIds(Arrays.asList(ids)));
    }

}
